﻿using Microsoft.Extensions.Configuration;
using System;
using System.Collections.Generic;
using System.IO;
using System.Text;

namespace WeChat.PlatForm.Common
{
    /// <summary>
    /// 用于APP使用
    /// </summary>
    public class AppConfig
    {

        /// <summary>
        /// 得到连接字符串
        /// </summary>
        public static string GetConnction
        {
            get
            {
                return GetConfig().GetSection("DB").GetSection("GetConnction").Value;
            }
        }

        /// <summary>
        /// 得到redis链接字符串
        /// </summary>
        public static string GetRedisConn
        {
            get
            {
                return GetConfig().GetSection("DB").GetSection("GetRedisConn").Value;
            }
        }


        /// <summary>
        /// 得到配置文件
        /// </summary>
        /// <returns></returns>
        private static IConfigurationRoot GetConfig()
        {
            var builder = new ConfigurationBuilder().SetBasePath(Directory.GetCurrentDirectory())//SetBasePath 设 置配置文件所在路径  
                .AddJsonFile("appsettings.json");
            var configRoot = builder.Build();
            return configRoot;
        }
    }
}
